<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
    <link rel="stylesheet" href="../../static/layui/css/layui.css" th:src="@{/static/layui/css/layui.css}" media="all">
    <link href="//hnres.etalk365.com/public/css/font-awesome-4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <style type="text/css">
        .bad-teach {
            display: flex;
            justify-content: flex-start;
            align-items: center;
            padding-left: 65px;
            flex-wrap:wrap;
        }
        .bad-teach-item {
            position: relative;
            /*width: 40px;*/
            height: 32px;
            padding-left: 50px;
            padding-right: 20px;
            background: rgba(247, 181, 94, 1);
            border-radius: .4rem;
            margin: 10px 10px;
            overflow: hidden;
        }
        .bad-teach-item > .del {
            position: absolute;
            top: 0;
            left: 0;
            width: 40px;
            height: 32px;
            text-align: center;
            line-height: 32px;
            background: rgba(70, 186, 125, 1);
            cursor: pointer;
            color: #fff;
        }
        .bad-teach-item > .name {
            display: block;
            background: rgba(247, 181, 94, 1);
            height: 32px;
            line-height: 32px;
            color: #fff;
        }
        .bad-teach_input {
            position: absolute;
            top: 34px;
            left: 0;
            width: 100%;
            max-height: 200px;
            overflow: auto;
            box-shadow: 0 1px 2px 0 #eee;
            z-index: 2;
            background: #fff;
            display: none;
        }
        .bad-teach_input-active {
            display: block;
        }
        .bad-teach_input:hover {
            display: block;
        }
        .bad-teach_input-wrap {
            position: relative;
            width: 180px;
            /* padding-left: 75px; */
            margin-right: 80px;
            border-radius: 4px;
        }
        .bad-teach_input-wrap_out {
            display: inline-block;
            padding-left: 75px;
            z-index: 1000;
            position: relative;
        }
        .input-wrap {
            height: 30px;
            width: 100%;
        }
        .add-btn {
            position: absolute;
            top: 0;
            right: -70px;
            height: 30px;
            line-height: 30px;
            width: 60px;
            text-align: center;
            border: 1px solid rgba(22, 155, 213, 1);
            background: rgba(22, 155, 213, 1);
            color: #fff;
            box-sizing: border-box;
            border-radius: 4px;
            cursor: pointer;
        }
        .item-input {
            box-sizing: border-box;
            width: 100%;
            height: 30px;
            line-height: 30px;
            padding: 0 10px;
            border-radius: 4px;
            border: 1px solid #aaa;
            color: #333;
        }
        .input-item {
            padding: 6px 10px;
        }
        .input-item:hover {
            background: #eee;
        }
        .no-data {
            min-height: 100px;
            line-height: 100px;
            text-align: center;
            border-radius: 4px;
        }
        /* #region 拖拽 */
        .drag-list-wrap {
            display: flex;
            justify-content: flex-start;
            align-items: flex-start;
            flex-wrap: wrap;
        }
        .draggable-title {
            min-width: 95px;
            padding: 10px 15px;
        }
        .draggable {
            padding: 25px 15px 0;
        }
        .draggable-wrap {
            display: flex;
            justify-content: flex-start;
            align-items: flex-start;
            flex-wrap: wrap;
        }
        .drag-list {
            display: flex;
            justify-content: flex-start;
            align-items: flex-start;
            flex-wrap: wrap;
            padding: 10px 15px;
        }
        .draggable-item {
            display: flex;
            justify-content: center;
            align-items: flex-start;
            flex-wrap: wrap;
            padding: 10px 15px;
            border: 1px solid #eee;
            border-radius: 4px;
            margin: 0 10px 15px 10px;
            cursor: pointer;
            position: relative;
        }
        .draggable-item_input {
            width: 300px;
            height: 100px;
            align-items: center;
            border: 1px dashed #eee;
        }
        .draggable-item .hover-wrap {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            display: none;
            border-radius: 4px;
        }
        .draggable-item:hover .hover-wrap {
            background: rgba(255, 184, 0, .2); /* hover 背景色 */
            display: flex;
            justify-content: center;
            align-items: center;
        }
        .hover-wrap .look {
            padding: 10px 15px;
            background: #FFB800;
            color: #fff;
            border-radius: 4px;

        }
        .hover-wrap .del {
            margin-left: 10px;
            background: red;
            color: #fff;
            border-radius: 4px;

        }
        .hover-wrap .setting {
            margin-left: 15px;
            background: #FFB800;
        }
        .draggable-item:hover {
            border: 1px solid #FFB800;
            box-shadow: 0 1px 2px 0 #eee;
        }
        .draggable-item > .draggable-img {
            max-width: 80px;
            min-width: 50px;
            margin-right: 8px;
        }
        .draggable-item > .draggable-img img {
            width: 100%;
        }

        /* 已选择常用老师 基本信息 */
        .draggable-info .text {
            font-size: 14px;
            line-height: 28px;
        }
        .draggable-info > .name {

        }
        .draggable-info > .level {

        }
        .draggable-info > .reservation {

        }
        .margin-top-s {
            margin-top: 10px;
        }
        .length-0-wrap {
            padding: 5px 30px;
        }
        .length-0 {
            width: 100%;
            height: 100px;
            border-radius: 6px;
            border: 1px dashed #eee;
            background: rgba(194, 194, 194, .1);
        }
        .flex-v-h-center {
            display: flex;
            width: 100%;
            height: 100%;
            justify-content: center;
            align-items: center;
        }
        /* #endregion 拖拽 */
    </style>
<body>
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
      <legend style="font-size: 18px;color: #19a2e3;font-weight: bold">学员常用老师设置</legend>
    </fieldset>
    <input type="hidden" id="personId" th:value="${personId}">
    <form class="layui-form" id="form1">
        <input type="hidden" th:value="${personId}" name="personId">
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px">学员性格：</label>
            <div class="layui-input-block">
              <input lay-filter="character" th:each="list:${characterList}" th:checked="${list.id == stuPrefer.character}"  th:value="${list.id}" type="radio" name="character" th:title="${list.levelName}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px">喜好老师性别：</label>
            <div class="layui-input-block">
              <input lay-filter="teacherSex" type="radio" th:checked="${stuPrefer.teacherSex==1}" name="teacherSex" value="1" title="男">
              <input lay-filter="teacherSex" type="radio" th:checked="${stuPrefer.teacherSex==2}" name="teacherSex" value="2" title="女">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px">学员英语基础：</label>
            <div class="layui-input-block">
             <input lay-filter="enBasis" name="enBasis" onclick="sysTeacherList()" th:checked="${stuPrefer.enBasis == list.id}" th:value="${list.id}" th:each="list:${BasicList}" type="radio" th:title="${list.levelName}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px">适合年龄段：</label>
            <div class="layui-input-block">
                <input lay-filter="ageGroup" name="ageGroup" th:checked="${stuPrefer.ageGroup == list.id}"  th:value="${list.id}" th:each="list:${ageGroupList}" type="radio" th:title="${list.levelName}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px">近两周上课率：</label>
            <div class="layui-input-inline">
                <select name="classPercent" lay-filter="classPercent">
                    <option value="">---预约率----</option>
                    <option value="1">40%以下</option>
                    <option value="2">40%-50%</option>
                    <option value="3">50%-60%</option>
                    <option value="4">60%以上</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px">自动约课设置：</label>
            <label class="layui-form-label">是否开启</label>
            <div class="layui-input-inline" style="width: 50px;">
                <input type="checkbox" name="switchAuto" lay-skin="switch" lay-text="ON|OFF" th:checked="${stuPrefer.switchAuto==1}" lay-filter="switchTest" value="1" title="是否开启">
            </div>
            <label class="layui-form-label" style="width: 180px;">是否允许预约非常用老师</label>
            <div class="layui-input-inline">
                <input type="checkbox" name="switchAllow" lay-skin="switch" lay-text="ON|OFF" th:checked="${stuPrefer.switchAllow==1}" lay-filter="switchTest" value="1" title="是否允许预约非常用老师">
            </div>
        </div>
        <div class="layui-form-item" th:if="${session.roleId!=2 && session.roleId!=12}">
            <label class="layui-form-label" style="width: 100px;"> </label>
            <a class="layui-btn layui-btn-sm layui-btn-normal" id="saveStuPrefer"> 保存筛选条件 </a>
            <em style="color: red">(重要提示：以上筛选条件设置完成后请先保存筛选条件再操作自动约课时间和设置常用老师，注意：自动约课默认扣1个币！！！)</em>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px"><i class="fa fa-asterisk fa-1" style="color: red;" aria-hidden="true"></i>常用上课时间</label>
            <div class="layui-table-box">
                <table class="layui-table" lay-size="sm" lay-filter="demoEvent" id="autoSetup">
                    <thead>
                        <tr>
                            <th >套餐</th>
                            <th class="text-center">周一</th>
                            <th class="text-center">周二</th>
                            <th class="text-center">周三</th>
                            <th class="text-center">周四</th>
                            <th class="text-center">周五</th>
                            <th class="text-center">周六</th>
                            <th class="text-center">周日</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr th:each="list:${autoClassTimeList}" th:id="${list.orderId}">
                            <td th:utext="${list.orderName}">套餐</td>
                            <td th:onclick="openAutoSetup([[${list.orderId}]],1)" style="cursor: pointer;">
                                <span th:each="monday,loopStatus:${list.listMonday}">
                                    <span th:text="${monday}"></span>
                                    <span th:if="${!loopStatus.last}" style="font-weight: bold;color: red;"> | </span>
                                    <input type="hidden" name="classTime" th:value="${monday}">
                                </span>
                            </td>
                            <td th:onclick="openAutoSetup([[${list.orderId}]],2)" style="cursor: pointer;">
                                <span th:each="tuesday,loopStatus:${list.listTuesday}">
                                    <span th:text="${tuesday}"></span><span th:if="${!loopStatus.last}" style="font-weight: bold;color: red;"> | </span>
                                    <input type="hidden" name="classTime" th:value="${tuesday}">
                                </span>
                            </td>
                            <td th:onclick="openAutoSetup([[${list.orderId}]],3)" style="cursor: pointer;">
                                <span th:each="wednesday,loopStatus:${list.listWednesday}">
                                    <span th:text="${wednesday}"></span><span th:if="${!loopStatus.last}" style="font-weight: bold;color: red;"> | </span>
                                    <input type="hidden" name="classTime" th:value="${wednesday}">
                                </span>
                            </td>
                            <td th:onclick="openAutoSetup([[${list.orderId}]],4)" style="cursor: pointer;">
                                <span th:each="thursday,loopStatus:${list.listThursday}">
                                    <span th:text="${thursday}"></span><span th:if="${!loopStatus.last}" style="font-weight: bold;color: red;"> | </span>
                                    <input type="hidden" name="classTime" th:value="${thursday}">
                                </span>
                            </td>
                            <td th:onclick="openAutoSetup([[${list.orderId}]],5)" style="cursor: pointer;">
                                <span th:each="friday,loopStatus:${list.listFriday}">
                                    <span th:text="${friday}"></span><span th:if="${!loopStatus.last}" style="font-weight: bold;color: red;"> | </span>
                                    <input type="hidden" name="classTime" th:value="${friday}">
                                </span>
                            </td>
                            <td th:onclick="openAutoSetup([[${list.orderId}]],6)" style="cursor: pointer;">
                                <span th:each="saturday,loopStatus:${list.listSaturday}">
                                    <span th:text="${saturday}"></span><span th:if="${!loopStatus.last}" style="font-weight: bold;color: red;"> | </span>
                                    <input type="hidden" name="classTime" th:value="${saturday}">
                                </span>
                            </td>
                            <td th:onclick="openAutoSetup([[${list.orderId}]],7)" style="cursor: pointer;">
                                <span th:each="sunday,loopStatus:${list.listSunday}">
                                    <span th:text="${sunday}"></span><span th:if="${!loopStatus.last}" style="font-weight: bold;color: red;"> | </span>
                                    <input type="hidden" name="classTime" th:value="${sunday}">
                                </span>
                            </td>
                        </tr>
                        <tr onclick="openAutoSetup('',0);" style="cursor: pointer;">
                            <td>添加自动约课</td>
                            <td> </td>
                            <td> </td>
                            <td> </td>
                            <td> </td>
                            <td> </td>
                            <td> </td>
                            <td> </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>

        <div id="dragList">
            <div class="drag-list-wrap">
                <!--#region 拖拽-->
                <div class="draggable-title"> 已选择常用老师 </div>
                <div class="length-0" v-if="!teacherList.length">
                    <div class="flex-v-h-center">
                        <div v-if="teacherListLoading">
                            正在获取数据...
                        </div>
                        <div v-else>
                            暂无常用老师
                        </div>
                    </div>
                </div>
                <div class="draggable">
                    <draggable v-model="teacherList" class="draggable-wrap" v-if="teacherList.length" @update="changePosition">
                        <div
                            v-for="(item, index) in teacherList"
                            v-if="item"
                            :key="index"

                            class="draggable-item">
                            <div class="draggable-img">
                                <img style="border-radius: 50%;"  :src="'https://hkres.etalk365.com'+item.pictures" onerror="javascript:this.src='../../static/img/teacherDefault.jpg';"/>
                            </div>
                            <div class="draggable-info">
                                <div class="text name">{{item.teacherLogin}}
                                    <img style="width: 15px" v-if="item.sex==1" src="../../static/img/man.png"/>
                                    <img style="width: 15px" v-if="item.sex==2" src="../../static/img/woman.png"/>
                                </div>
                                <div class="text level">{{item.levelName}}（五星率：{{toPercent(item.fiveStarPercent)}}）</div>
                                <div class="text reservation" title="当前时间后的符合自动约课时间的课程预约率">约课率（{{toPercent(item.appointmentPercent)}}）</div>
                                <div class="text reservation" title="实际匹配数/设置时间数">匹配度（{{item.matchNum}}/{{item.countMatchNum}}）</div>
                            </div>
                            <div class="hover-wrap">
                                <span class="look" @click="look(item.personId,item.teacherLogin)"> 查看资料 </span>
                                <span class="look del" th:if="${session.roleId!=2 && session.roleId!=12}" @click="del(item.personId)"> 删&nbsp;&nbsp;&nbsp;&nbsp;除 </span>
                            </div>
                        </div>
                    </draggable>
                    <div
                        class="draggable-item draggable-item_input"
                        v-show="teacherList.length < maxNum && !teacherListLoading">
                        <div class="bad-teach_input-wrap" id="dragTeachInputWrap">
                                <div class="input-wrap">
                                        <input
                                            type="text"
                                            class="item-input"
                                            placeholder="请输入老师的名字"
                                            maxlength="100"
                                            v-model="text"
                                            @input="input"
                                            @blur="blur"
                                            @focus="focus">
                                        <div class="add-btn" @click="add">添加</div>
                                </div>
                                <div
                                    class="bad-teach_input"
                                    :class="{
                                        'bad-teach_input-active': (show || text) && !outStatus
                                    }">
                                    <div v-if="inputList.length">
                                        <div
                                            class="input-item"
                                            v-for="(item, index) in inputList"
                                            :key="'name' + index"
                                            @click="addItm(item)">
                                            {{item.teacherLogin}} | {{item.sex==1?"男":"女"}} | {{item.levelName}}
                                        </div>
                                    </div>
                                    <div v-else class="no-data">
                                        暂无数据
                                    </div>
                                </div>
                            </div>
                    </div>
                </div>
                <!--#endregion 拖拽-->
            </div>

            <!--<div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px">排序选择</label>
                <label class="layui-form-label" style="width: 180px;">匹配度由高到低排序</label>
                <div class="layui-input-inline" style="width: 50px;">
                    <input type="checkbox" name="switch" lay-skin="switch" lay-text="ON|OFF" lay-filter="switchTest" value="1" title="是否开启">
                </div>
                <label class="layui-form-label" style="width: 180px;">上课率(COR)低到高排序</label>
                <div class="layui-input-inline">
                    <input type="checkbox" name="switch" lay-skin="switch" lay-text="ON|OFF" lay-filter="switchTest" value="1" title="是否允许预约非常用老师">
                </div>
            </div>-->
            <input type="hidden" id="page" value="1">
            <div class="drag-list-wrap">
                <div class="draggable-title"> 系统推荐 </div>
                <div class="drag-list" v-if="sysTeacherList.length">
                    <div v-for="(item, index) in sysTeacherList" v-if="item" :key="index" class="draggable-item">
                        <div class="draggable-img">
                            <img style="border-radius: 50%;"  :src="'https://hkres.etalk365.com'+item.pictures" onerror="javascript:this.src='../../static/img/teacherDefault.jpg';"/>
                        </div>

                        <div class="draggable-info">
                            <div class="text name">{{item.teacherLogin}}
                                    <img style="width: 15px" v-if="item.sex==1" src="../../static/img/man.png"/>
                                    <img style="width: 15px" v-if="item.sex==2" src="../../static/img/woman.png"/>
                                </div>
                            <div class="text level">{{item.levelName}}（五星率：{{toPercent(item.fiveStarPercent)}}）</div>
                            <div class="text reservation" title="当前时间后的符合自动约课时间的课程预约率">约课率（{{toPercent(item.appointmentPercent)}}）</div>
                            <!--<div class="text reservation" title="匹配率">匹配率（{{toPercent(item.matchPercent)}}）</div>-->
                            <div class="text reservation" title="实际匹配数/设置时间数">匹配度（{{item.matchNum}}/{{item.countMatchNum}}）</div>
                        </div>
                        <div class="hover-wrap">
                            <span class="look" @click="look(item.personId,item.teacherLogin)"> 查看资料 </span>
                            <span class="look setting" th:if="${session.roleId!=2 && session.roleId!=12}" @click="setting(item.personId)"> 设置常用 </span>
                        </div>
                    </div>
                </div>
                <div class="length-0" v-if="!sysTeacherList.length">
                    <div class="flex-v-h-center">
                        <div v-if="sysTeacherListLoading">
                        <!-- <div v-if="teacherListLoading"> -->
                            正在获取数据...
                        </div>
                        <div v-else>
                            暂无推荐的老师
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block " v-if="sysTeacherList.length" style="margin-top: 20px">
               <!-- <a class="layui-btn layui-btn-sm layui-btn-normal" id="saveStuPrefer"> 保存筛选条件 </a>-->
                <a class="layui-btn layui-btn-sm layui-btn-normal"  th:if="${session.roleId!=2 && session.roleId!=12}" onclick="sysTeacherList('next')">换一批</a>
            </div>
        </div>
    </form>
    <form class="layui-form" id="form2">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
          <legend style="font-size: 18px;color: #19a2e3;font-weight: bold">ET信息备注</legend>
        </fieldset>

        <div class="layui-form-item layui-form-text" th:each="list,istatus:${listMap}">
             <label class="layui-col-lg1 layui-col-sm2" th:utext="${list.sceneCnName}" th:with="prefSceneId=${0}" style="text-align: right;padding-right: 10px;padding-top: 10px;"></label>
             <input th:if="${list.sceneMultiselect !=1}" type="hidden" th:id="'prefVal'+${list.sceneId}" name="prefVal.sceneInfoId">
             <div class="layui-col-lg11 layui-col-sm10" >
                 <span th:each="list2:${list.sceneInfoList}">
                     <span th:if="${list2.childList==null || list2.childList.size()==0}">
                        <input th:if="${list.sceneMultiselect!=1  and list2.sceneInfoCnName != '自定义'}" type="radio" th:value="${list2.sceneInfoCnName}" lay-filter="rad"
                            th:attr="sceneInfoId=${list2.sceneInfoId},sceneId=${list.sceneId}" th:title="${list2.sceneInfoCnName}" th:checked="${list2.defaultVal==1}" th:name="'personsce'+${list.sceneId}">
                        <!--多选框-->
                        <input  th:if="${list.sceneMultiselect==1 and list2.exclusive==0}" lay-filter="check" th:attrappend="data-checkbox=${list.sceneId+'0'}"
                                th:name="'personsce'+${list.sceneId}" th:attr="sceneInfoId=${list2.sceneInfoId},sceneId=${list.sceneId}"
                         th:value="${list2.sceneInfoCnName}" th:title="${list2.sceneInfoCnName}" th:checked="${list2.defaultVal==1}" type="checkbox"  lay-skin="primary">
                        <input  th:if="${list.sceneMultiselect==1 and list2.exclusive==1}" lay-filter="check" th:attrappend="data-checkbox=${list.sceneId+'1'}"
                                th:name="'personsce'+${list.sceneId}" th:attr="sceneInfoId=${list2.sceneInfoId},sceneId=${list.sceneId}"
                         th:value="${list2.sceneInfoCnName}" th:title="${list2.sceneInfoCnName}" th:checked="${list2.defaultVal==1}" type="checkbox"  lay-skin="primary">

                         <input type="hidden" th:if="${list.sceneMultiselect==1 and list2.exclusive==0}" th:attrappend="data-checkbox=${list.sceneId+'0'}"  name="prefVal.sceneInfoId" th:id="'prefVal'+${list2.sceneInfoId}">
                        <input type="hidden" th:if="${list.sceneMultiselect==1 and list2.exclusive==1}" th:attrappend="data-checkbox=${list.sceneId+'1'}" name="prefVal.sceneInfoId" th:id="'prefVal'+${list2.sceneInfoId}">

                         <!--自定义输入框-->
                         <textarea th:each="list2:${list.sceneInfoList}" th:if="${list2.sceneInfoCnName == '自定义'}" th:text="${list2.customValue}"
                         placeholder="请输入内容" class="layui-textarea" onfocus="isfocus(this)" th:attr="sceneInfoId=${list2.sceneInfoId},sceneId=${list.sceneId}" th:id="'customValue'+${list2.sceneInfoId}"></textarea>
                     </span>
                     <span th:if="${list2.childList!=null && list2.childList.size()>0}">
                         <p style="margin-bottom: 10px;">
                         <label  th:text="${list2.sceneInfoCnName+'：'}" style="font-weight: bold;vertical-align: bottom;"></label>
                         <span style="margin-bottom: 20px;" th:each="list3:${list2.childList}">
                             <input th:if="${list.sceneMultiselect!=1  and list3.sceneInfoCnName != '自定义'}" type="radio" th:value="${list3.sceneInfoCnName}" lay-filter="rad"
                                    th:attr="sceneInfoId=${list3.sceneInfoId},sceneId=${list.sceneId}" th:title="${list3.sceneInfoCnName}" th:checked="${list3.defaultVal==1}" th:name="'personsce'+${list.sceneId}">
                             <!--多选框-->
                             <input  th:if="${list.sceneMultiselect==1 and list3.exclusive==0}" lay-filter="check" th:attrappend="data-checkbox=${list.sceneId+'0'}"
                                    th:name="'personsce'+${list.sceneId}" th:attr="sceneInfoId=${list3.sceneInfoId},sceneId=${list.sceneId}"
                                    th:value="${list2.sceneInfoCnName}" th:title="${list3.sceneInfoCnName}" th:checked="${list3.defaultVal==1}" type="checkbox"  lay-skin="primary">
                             <input  th:if="${list.sceneMultiselect==1 and list3.exclusive==1}" lay-filter="check" th:attrappend="data-checkbox=${list.sceneId+'1'}"
                                     th:name="'personsce'+${list.sceneId}" th:attr="sceneInfoId=${list3.sceneInfoId},sceneId=${list.sceneId}"
                                    th:value="${list2.sceneInfoCnName}" th:title="${list3.sceneInfoCnName}" th:checked="${list3.defaultVal==1}" type="checkbox"  lay-skin="primary">
                             <input type="hidden" th:if="${list.sceneMultiselect==1 and list3.exclusive==0}" th:attrappend="data-checkbox=${list.sceneId+'0'}" th:value="${list3.defaultVal==1?list3.sceneInfoId:''}" name="prefVal.sceneInfoId" th:id="'prefVal'+${list3.sceneInfoId}">
                             <input type="hidden" th:if="${list.sceneMultiselect==1 and list3.exclusive==1}" th:attrappend="data-checkbox=${list.sceneId+'1'}" th:value="${list3.defaultVal==1?list3.sceneInfoId:''}" name="prefVal.sceneInfoId" th:id="'prefVal'+${list3.sceneInfoId}">
                        </span></p>
                     </span>
                 </span>
             </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-col-lg1 layui-col-sm2"><div style="text-align: right;padding-right: 10px;padding-top: 10px;">中教学习建议</div></label>
            <div class="layui-col-lg11 layui-col-sm10" >
                <textarea th:text="${suggestion}" placeholder="中教学习建议" id="ltSuggestion" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item" th:if="${session.roleId!=2 && session.roleId!=12}">
            <div class="layui-input-block">
              <a class="layui-btn" id="setPref" >保 存</a>
            </div>
        </div>
    </form>

    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
          <legend style="font-size: 18px;color: #19a2e3;font-weight: bold">黑名单老师</legend>
    </fieldset>
    <!--<form class="layui-form">-->
          <div id="badTeach">
                <div class="bad-teach">
                        <div
                            class="bad-teach-item"
                            v-for="(item, index) in badTeachList"
                            :key="'teatch' + index">
                                <div class="del" th:if="${session.roleId!=2 && session.roleId!=12}" @click="del(item.id)"><i class="fa fa-times"></i></div>
                                <div class="name">{{item.teacherLogin}}</div>
                        </div>
                </div>
                <div class="bad-teach_input-wrap_out">
                    <div class="bad-teach_input-wrap" id="badTeachInputWrap">
                        <div class="input-wrap" th:if="${session.roleId!=2 && session.roleId!=12}">
                                <input
                                    type="text"
                                    class="item-input"
                                    placeholder="请输入老师的名字"
                                    maxlength="100"
                                    v-model="text"
                                    @input="input"
                                    @blur="blur"
                                    @focus="focus">
                                <div class="add-btn" @click="add">添加</div>
                        </div>
                        <div
                            class="bad-teach_input"
                            :class="{
                                'bad-teach_input-active': (show || text) && !outStatus
                            }">
                            <!-- && !outStatus -->
                            <div v-if="inputList.length">
                                <div
                                    class="input-item"
                                    v-for="(item, index) in inputList"
                                    :key="'name' + index"
                                    @click="addItm(item)">
                                    {{item.teacherLogin}} | {{item.sex==1?"男":"女"}} | {{item.levelName}}
                                </div>
                            </div>
                            <div v-else class="no-data">
                                暂无数据
                            </div>
                        </div>
                    </div>
                </div>
        </div>
    <!--</form>-->
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
          <legend style="font-size: 18px;color: #19a2e3;font-weight: bold">历史老师五星榜</legend>
    </fieldset>
    <div class="content" style="width: 45%;margin-left: 70px;">
        <div class="layui-col-md14" style="margin-top: -10px">
            <table class="layui-hide" id="fiveStarTeacherList"></table>
        </div>
    </div>

    <script src="https://hkres.etalk365.com/public/lib/jquery/jquery.min.js" type="text/javascript"></script>
    <!--#endregion 拖拽组件-->
    <script type="text/javascript" src="../../static/js/vue.min.js" th:src="@{/static/js/vue.min.js}"></script>
    <script src="https://cdn.jsdelivr.net/npm/sortablejs@1.7.0/Sortable.min.js"></script>
    <script src="https://hnres.etalk365.com/public/lib/Vue.Draggable/2.23.2/vuedraggable.umd.min.js"></script>
    <script src="https://hnres.etalk365.com/public/lib/layer/layer.js"></script>
    <!--#endregion 拖拽组件-->
    <script src="../../static/layui/layui.js" th:src="@{/static/layui/layui.js}" ></script>

    <script>

        $("textarea").parent().prev().removeAttr("style");
        function isfocus(obj){
            var sceneId = $(obj).attr("sceneId");
            var sceneInfoId = $(obj).attr("sceneInfoId");
           $("#prefVal"+sceneId).val(sceneInfoId);
        }
        //学员偏好提交
        $("#saveStuPrefer").click(function() {

           $.ajax({
                data: $('#form1').serialize(),// 序列化表单值 ,
                type: "POST",
                dataType: "JSON",
                url: "/student/info/stuPreferencesSave",
                // contentType:"application/json;charset=utf-8",
                beforeSend: function () {
                    // 禁用
                    $("#saveStuPrefer").addClass('layui-btn-disabled');
                },
                complete: function () {
                    // 启用
                    $("#saveStuPrefer").removeClass('layui-btn-disabled');
                },
                success: function (result) {
                    if(result.code >0){
                        layer.msg("学员常用老师设置修改成功", {icon: 1});
                    }else{
                         layer.msg("学员常用老师设置修改失败", {icon: 2});
                    }
                }
            });
        });

        $("#setPref").click(function(){
            etInfo();
        });
        //提交et 信息备注
        function etInfo() {
            var dataobj = {};
            // dataobj.personId = $("#personId").val();
            dataobj.prefVal = [];
            dataobj.personId = $("#personId").val();
            $("input[name='prefVal.sceneInfoId']").each(function(i){
                if($(this).val()!=null && $(this).val()!=""){
                    var obj=$("#customValue"+$(this).val());
                    if(obj.length>0){
                        obj.val($.trim(obj.val()));
                        if($.trim(obj.val())==""){
                            obj.addClass("layui-form-danger");
                            layer.msg("请输入自定义内容", {icon: 2});
                            return false;
                        }
                        if($.trim(obj.val())!=""){
                            dataobj.prefVal.push({"sceneInfoId":$(this).val(),"customValue":obj.val()});
                        }
                    }else{
                        dataobj.prefVal.push({"sceneInfoId":$(this).val()});
                    }
                }
            });
            dataobj.ltSuggestion=$("#ltSuggestion").val();
            $.ajax({
                type:'post',
                url:'/student/info/saveEtInfoInfo',
                data : JSON.stringify(dataobj),
                dataType:"json",
                contentType: "application/json;charset=utf-8",
                success:function(data){
                    if(data.code >0){
                        layer.msg("ET信息备注修改成功", {icon: 1});
                    }else{
                         layer.msg("ET信息备注修改失败", {icon: 2});
                    }
               }
            });
        }

        layui.use(['form', 'layedit', 'laydate','table'], function(){
            var form = layui.form
            ,layer = layui.layer
            ,laydate = layui.laydate
            ,table =  layui.table;
            var layedit = layui.layedit;

           form.on('checkbox(check)', function (data) {
                let sceneId = data.elem.getAttribute("sceneId");
                let sceneInfoId = data.elem.getAttribute("sceneinfoid");
                if(data.elem.checked){
                    $("#prefVal"+sceneInfoId).val(sceneInfoId);
                    $("input[name='personsce"+sceneId+"']:checked").each(function () {
                        if($(data.elem).data("checkbox")!=$(this).data("checkbox")){
                            $(this).attr("checked",false);
                            $(this).next().removeClass("layui-form-checked");
                            $("#prefVal"+$(this).attr("sceneinfoid")).val("");
                        }
                    })
                }else{
                    $("#prefVal"+sceneInfoId).val("");
                }

            });

            form.on('radio(rad)', function (data) {
                 var sceneId = data.elem.getAttribute("sceneId");
                 var sceneInfoId = data.elem.getAttribute("sceneinfoid");
                 if(data.elem.checked){
                    $("#prefVal"+sceneId).val(sceneInfoId);
                 }else{
                     $("#prefVal"+sceneId).val();
                 }
            });

            form.on('radio(character)', function (data) {
                if(data.elem.checked){
                    sysTeacherList();
                }
            });
            //年龄
            form.on('radio(ageGroup)', function (data) {
                if(data.elem.checked){
                    sysTeacherList();
                }
            });

            form.on('radio(teacherSex)', function (data) {
                if(data.elem.checked){
                    sysTeacherList();
                }
            });

            form.on('radio(enBasis)', function (data) {
                if(data.elem.checked){
                    sysTeacherList();
                }
            });

            form.on('select(monday)', function (data) {
                sysTeacherList();
            });

            form.on('select(tuesday)', function (data) {
                sysTeacherList();
            });

            form.on('select(wednesday)', function (data) {
                 sysTeacherList();
            });

            form.on('select(thursday)', function (data) {
                 sysTeacherList();
            });

            form.on('select(friday)', function (data) {
                sysTeacherList();
            });

            form.on('select(saturday)', function (data) {
                 sysTeacherList();
            });

            form.on('select(sunday)', function (data) {
                sysTeacherList();
            });

            form.on('select(classPercent)', function (data) {
                sysTeacherList();
            });
            form.render();
            //table
            table.render({
                elem: '#fiveStarTeacherList',
                url:'/student/info/fiveStarTeacherPercent?personId='+$("#personId").val(),
                method: 'POST', //方式
                height: "300",
                width:"620",
                loading: true, //翻页加loading
                page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                  layout: ['count', 'prev', 'page', 'next', 'skip'], //自定义分页布局
                  //,curr: 5 //设定初始在第 5 页
                  groups: 5, //只显示 1 个连续页码
                  first: false, //不显示首页
                  last: false, //不显示尾页
                  theme: '#00A0E9'
                },
                cols: [
                    [
                      {type:'numbers', title: '序号',fixed: 'left'},
                      {field:'teacherLogin', title: '老师',fixed: 'left'},
                      {field: 'fiveStarPercent', title: '五星率' ,templet : function (row){
                          return toPercent(row.fiveStarPercent);
                      }},
                      {field: 'lessonCounter', title: '节数' },
                      {field:'finishedLessonPercent', title: '近两周上课率',templet : function (row){
                          return toPercent(row.finishedLessonPercent);
                      }},
                      {field:'', title: '操作',
                      templet : function (row) {
                         return '<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="del" onclick="addCommonlyUsedTeacher('+row.personId+')" href="javascript:void(0);">设置常用老师</a>';
                      }
                    },
                    ]
                ],
                id : "selectTrackRemind"
            });
        });

        $(function(){
           blackListTeacher();
           //常用老师列表
           commonlyUsedTeacherInfoList();
           //系统推荐
           sysTeacherList(1);

        });

        /*小数转百分数*/
        /*Number()数据类型转换，指定截取转换后的小数点后几位(四舍五入)*/
        function toPercent(point){
            let str = Math.round(Number(point*100)).toFixed(0);
            str+="%";
            return str;
        }

        //黑名单老师
        function blackListTeacher(){
            $.ajax({
                type:'post',
                url:'/student/info/blackListTeacher',
                data : {"personId" : $("#personId").val()},//数据，这里使用的是Json格式进行传输JSON.stringify(data),
                dataType:"json",
                success:function(data){
                    if(data.code >0){
                        badTeach.badTeachList = data.blackTeacherList;
                    }else{
                         layer.msg("请求失败", {icon: 2});
                    }
               },
              error : function(xhr, type, exception) {
                  layer.msg(xhr.responseText, "Failed", {icon: 2});
              }
            });
        }

        //老师列表 type 1 系统推荐老师搜索  2黑名单老师搜索
        function searchByTeacherName(teacherLogin,type){
            $.ajax({
                type:'post',
                url:'/student/info/searchByTeacherName',
                data : {"teacherLogin" : teacherLogin},
                dataType:"json",
                success:function(data){
                    if(data.code >0){
                        if(type==1){
                            dragList.inputList = data.searchByTeacherName;
                        }else{
                            badTeach.inputList = data.searchByTeacherName;
                        }
                        console.info(data.searchByTeacherName);
                    }else{
                         layer.msg("数据请求异常", {icon: 2});
                    }
               },
              error : function(xhr, type, exception) {
                  layer.msg(xhr.responseText, "Failed", {icon: 2});
              }
            });
        }

        //添加黑名单老师
        function addBadTeacher(teacherLogin){
            $.ajax({
                type:'post',
                url:'/student/info/addBadTeacher',
                data : {"teacherLogin" : teacherLogin,"personId" : $("#personId").val()},
                dataType:"json",
                success:function(data){
                    if(data.code >0){
                       layer.msg("添加成功", {icon: 1});
                       blackListTeacher();
                    }else if(data.code==-1){
                         layer.msg("该老师已经在黑名单里,请勿重复提添加", {icon: 2});
                    }
               },
              error : function(xhr, type, exception) {
                  layer.msg(xhr.responseText, "Failed", {icon: 2});
              }
            });
        }

        //常用老师列表
        function commonlyUsedTeacherInfoList(){
             dragList.teacherList = [];
            dragList.teacherListLoading = true;
            $.ajax({
                type:'post',
                url:'/student/info/teacherInfoList',
                data : {"personId" : $("#personId").val()},
                dataType:"json",
                success:function(data){
                    if(data.code >0){
                      dragList.teacherList = data.teacherInfoList;
                    }else{
                        layer.msg("数据请求异常", {icon: 2});
                    }
                    dragList.teacherListLoading = false
               },
              error : function(xhr, type, exception) {
                  layer.msg(xhr.responseText, "Failed", {icon: 2});
                  dragList.teacherListLoading = false
              }
            });
        }

        //系统推荐
        function sysTeacherList(type){
            let page;
            if(type=='next'){
                page = (parseInt($("#page").val()))+1;
            }else{
                page = 1
            }

            $("#page").val(page);
            let dataobj = {};
            dataobj.page = page;
            let character = $("input[name='character']:checked");
            if(character.length>0){
                 dataobj.character = character.val();
            }
            let teacherSex = $("input[name='teacherSex']:checked");
            if(teacherSex.length>0){
                 dataobj.teacherSex = teacherSex.val();
            }
            let enBasis = $("input[name='enBasis']:checked");
            if(enBasis.length >0){
                 dataobj.enBasis = enBasis.val();
            }
            let isClassTimeSelected=$("input[name='classTime']").length>0;

            if (!isClassTimeSelected) {
                dragList.sysTeacherListLoading = false;
                dragList.sysTeacherList=[];
                layer.msg("常用上课时间必选一天，否则没有推荐常用老师", {icon: 2});
                return false;
            }
            let classPercent = $("select[name='classPercent']");
            //alert($("select[name='classPercent']").val());
            if(classPercent.length >0){
                 dataobj.classPercent = classPercent.val();
            }
            let ageGroup = $("input[name='ageGroup']:checked");
            if(ageGroup.length >0){
                 dataobj.ageGroup = ageGroup.val();
            }
            dataobj.personId = $("#personId").val();

            dragList.sysTeacherList = [];
            dragList.sysTeacherListLoading = true;
            $.ajax({
                type:'post',
                url:'/student/info/teacherLevelInfo',
                data : JSON.stringify(dataobj),
                contentType:"application/json;charset=utf-8",
                dataType:"json",
                success:function(data){
                    if(data.code >0){
                      dragList.sysTeacherList = data.pageInfo.list;
                      if (data.pageInfo.pages<page){
                          $("#page").val(0);
                      }
                        // console.log(data.pageInfo.list)
                    }else{
                        layer.msg("数据请求异常", {icon: 2});
                    }
                    dragList.sysTeacherListLoading = false
               },
              error : function(xhr, type, exception) {
                  layer.msg(xhr.responseText, "Failed", {icon: 2});
                  dragList.sysTeacherListLoading = false
              }
            });
        }

        //添加常用老师
        function addCommonlyUsedTeacher(teacherId) {
            $.ajax({
                type:'post',
                url:'/student/info/addCommonlyUsedTeacher',
                data : {"teacherId" : teacherId,"personId" : $("#personId").val()},
                dataType:"json",
                success:function(data){
                    if(data.code >0){
                      layer.msg("添加成功", {icon: 1});
                      commonlyUsedTeacherInfoList();
                    }else if(data.code == -1){
                       layer.msg("该老师已经是常用老师了,请勿重复添加", {icon: 2});
                    }else if(data.code == -2){
                        layer.msg("常用老师已达到上限,请联系管理员", {icon: 2});
                    }else{
                       layer.msg("数据请求异常", {icon: 2});
                    }
               },
              error : function(xhr, type, exception) {
                  layer.msg(xhr.responseText, "Failed", {icon: 2});
              }
            });
        }

        /**
         * 常用老师换顺序
         **/
        function changeCommonTeacherPosition(oldIndex,newIndex) {
            let param={"originalIndex":oldIndex,"newIndex":newIndex,"personId" : $("#personId").val()};
            $.post("/student/info/changeCommonlyUsedTeacher",param,function (result) {
                if (result===null || result.status!=1){
                    layer.msg("更改常用老师顺序失败，请刷新页面重试",{icon:2});
                }
            },"json");
        }

        /**
         * @description 黑名单
         */
        var badTeach = new Vue({
            el: '#badTeach',
            data: {
                addItem: {},
                show: false, // 获取焦点
                text: '',
                outStatus: false, // 点击外部的状态
                badTeachList: [ /** @description 黑名单老师 */ ],
                inputList: [ /** @description 模糊匹配 */ ]
            },
            methods: {
                /**
                 * @description
                 * 点击每一项，删除一项
                 */
                del(id) {
                    layer.confirm('是否确认删除？删除后数据不可恢复', {
                      btn: ['是','否'] //按钮
                      ,cancel: function(index, layero){

                      }
                    }, function(){
                       $.ajax({
                            type:'post',
                            url:'/student/info/delBadTeacher',
                            data : {"id" : id},//数据，这里使用的是Json格式进行传输JSON.stringify(data),
                            dataType:"json",
                            success:function(data){
                                if(data.code >0){
                                   layer.msg("删除成功", {icon: 1});
                                   blackListTeacher();
                                }else{
                                   layer.msg("删除失败", {icon: 2});
                                }
                           },
                          error : function(xhr, type, exception) {
                              layer.msg(xhr.responseText, "Failed", {icon: 2});
                          }
                        });
                    });
                },
                /**
                 * @description
                 * 点击每一项，添加新老师
                 */
                add() {
                    if (!badTeach.addItem.teacherLogin) {
                        layer.msg('请选择老师', {icon: 2});
                   }
                   addBadTeacher(badTeach.addItem.teacherLogin) // 新增
                },
                /**
                 * @description
                 * 点击每一项，添加新老师到 addItem 变量
                 */
                addItm(item) {
                    badTeach.addItem = item // @todo 重要的数据点击之后获取的一项
                    badTeach.text = item.teacherLogin
                },
                /**
                 * @description
                 * input 输入的时候，获取通过ajax 获取数据，并改变 input 输入框
                 */
                input() {
                    searchByTeacherName(badTeach.text,2);
                },
                /**
                 * @description
                 * input 获取焦点
                 */
                focus() {
                    badTeach.outStatus = false
                    badTeach.show = true
                },
                /**
                 * @description
                 * input 失去焦点
                 */
                blur() {
                    badTeach.show = false
                }
            }
        })


        /** #endregion 拖拽组件 */
        var dragList = new Vue({
            el: '#dragList',
            data: {
                show: false, // 获取焦点
                text: '',
                teacherListLoading: true,
                sysTeacherListLoading: true,
                addItem: {},
                maxNum: 3, // 
                outStatus: false, // 点击外部的状态
                inputList: [ /** @description 模糊匹配 */ ],
                teacherList: [ /** @description 黑名单老师 */ ],
                sysTeacherList: [ /** @description 系统设置老师 */ ]
            },

            methods: {
                                /**
                 * @description
                 * 点击每一项，删除一项
                 */
                //  del(item) {
                //     alert(item.name)
                //     console.log(item)
                // },
                /**
                 * @description
                 * 点击每一项，添加新老师
                 */
                add() {
                    if (!dragList.addItem.teacherLogin) {
                        layer.msg('请选择老师', {icon: 2})
                    }
                   addCommonlyUsedTeacher(dragList.addItem.personId);
                },
                /**
                 * @description
                 * 点击每一项，添加新老师到 addItem 变量
                 */
                addItm(item) {
                    dragList.addItem = item // @todo 重要的数据点击之后获取的一项
                    dragList.text = item.teacherLogin;
                },
                /**
                 * @description
                 * input 输入的时候，获取通过ajax 获取数据，并改变 input 输入框
                 */
                input() {
                    dragList.outStatus = false
                    searchByTeacherName(this.text,1);
                },
                /**
                 * @description
                 * input 获取焦点
                 */
                focus() {
                    dragList.outStatus = false
                    this.show = true
                },
                /**
                 * @description
                 * input 失去焦点
                 */
                blur() {
                    this.show = false
                },
                /**
                 * @description 在 Vue 实例内部调用 look 方法可查看资料
                 * @param {Object} 老师的数据
                 */
                look(teacherId,teacherLogin) {
                    teacherInfo(teacherId,teacherLogin);
                },

                del(teacherId){
                    layer.confirm('是否确认删除常用老师？', {
                      btn: ['是','否'] //按钮
                      ,cancel: function(index, layero){

                      }
                    }, function(){
                         delTeacher(teacherId);
                    });
                },
                /**
                 * @description 在 Vue 实例内部调用 look 方法可设置常用
                 * @param {Object} 老师的数据
                 */
                setting(teacherId) {

                    addCommonlyUsedTeacher(teacherId);
                },

                /**
                 * 移动位置方法
                 */
                changePosition(evt) {
                    // alert(evt.oldIndex)  // 可以知道拖动前的位置
                    // alert(evt.newIndex)  // 可以知道拖动后的位置

                    changeCommonTeacherPosition(evt.oldIndex+1,evt.newIndex+1);
                }
            }

        });
        /**
         tescription 通过 dragList.teacheList 获取整个数组
         * 在 Vue 实例内部调用 look 方法可查看资料
         */
        // var list1 = [
        //     {
        //         'imgSrc': 'https://hnres.etalk365.com/crm/test_paper/default.png', // 老师画像
        //         'name': 'James', // 老师名称
        //         'leval': '铂金级', // 等级
        //         'favorableRate': '95%' // 五星率
        //     },
        //     {
        //         'imgSrc': 'https://hnres.etalk365.com/crm/test_paper/default.png',
        //         'name': 'James2',
        //         'leval': '白金级',
        //         'favorableRate': '85%'
        //     }
        // ]
        // dragList.teacherList = dragList.teacherList.concat(list1)
        // dragList.sysTeacherList = dragList.sysTeacherList.concat(list1)
        /** #endregion 拖拽组件 */

        document.addEventListener('click', function (e) {
            if ($('#dragTeachInputWrap')[0].contains(e.target)) {
            } else {
                dragList.show = false // 获取焦点
                dragList.outStatus = true // 点击外部
            }
            if ($('#badTeachInputWrap')[0].contains(e.target)) {
            } else {
                badTeach.show = false // 获取焦点
                badTeach.outStatus = true // 点击外部
            }
        })

        function  delTeacher(teacherId){
           $.ajax({
                type:'post',
                url:'/stuDynamic/delTeacher',
                data : {"teacherId" : teacherId,"personId" : $("#personId").val()},//数据，这里使用的是Json格式进行传输JSON.stringify(data),
                dataType:"json",
                success:function(data){
                    if(data.code >0){
                       layer.msg("删除成功", {icon: 1});
                       commonlyUsedTeacherInfoList();
                    }else{
                       layer.msg("删除失败", {icon: 2});
                    }
               },
              error : function(xhr, type, exception) {
                  layer.msg(xhr.responseText, "Failed", {icon: 2});
              }
            });
        }
    </script>
    <script>
        /**
         * 教师信息卡片弹窗
         * @param teacherId 老师id(personId)
         * @param teacherLogin 老师登录名
         */
    function teacherInfo(teacherId,teacherLogin){
       let url = "/personCtl/teacher/info/"+teacherId+"/"+$("#personId").val();

        layer.open({
            type: 2,
            title: false,
            closeBtn: 1, //显示关闭按钮
            shade: [0.5],
            area: ['80%', '90%'],
            //offset: 'rb', //右下角弹出
            // time: 2000, //2秒后自动关闭
            anim: 2,
            content: [url, 'yes'], //iframe的url，no代表不显示滚动条
        });
    }

    //监听常用上课时间表格单元格事件
    layui.use('table', function(){
        let table = layui.table;
        //监听单元格事件
        table.on('tool(demoEvent)', function(obj){
            let data = obj.data;
            if(obj.event === 'setSign'){
                layer.prompt({
                    formType: 2
                    ,title: '修改 ID 为 ['+ data.id +'] 的用户签名'
                    ,value: data.sign
                }, function(value, index){
                    layer.close(index);

                    //这里一般是发送修改的Ajax请求

                    //同步更新表格和缓存对应的值
                    obj.update({
                        sign: value
                    });
                });
            }
        });
    });

    function openAutoSetup(orderId,weekId) {
        let personId="[[${personId}]]";
        let url="/student/auto/class/setup/init?personId="+personId;
        if (null != orderId){
            url+="&orderId="+orderId;
        }
        if (null != weekId){
            url+="&weekId="+weekId;
        }
        layer.open({
            type: 2,
            title: false,
            closeBtn: 1, //显示关闭按钮
            shade: [0.5],
            area: ['80%', '90%'],
            //offset: 'rb', //右下角弹出
            // time: 2000, //2秒后自动关闭
            anim: 2,
            content: [url, 'yes'], //iframe的url，no代表不显示滚动条
            end:function (index, layero) {

                let params=sessionStorage.getItem(personId);
                // console.log(params);
                if (params!==null && params!==""){
                    let jsonParams=JSON.parse(params);
                    updateTable(jsonParams,orderId);
                }
                sessionStorage.removeItem(personId);
            }
        });
    }
    function updateTable(jsonParams,orderId) {
        let times=jsonParams.classTimes;
        let timeText=times.join("<span style=\"font-weight: bold;color: red;\"> | </span>");
        let weeks=jsonParams.weeks;
        let orders=jsonParams.orderName;
        let td="";
        let removeTr=true;
        let trObj=$("#"+orderId);
        for (let i=0;i<orders.length;i++){
            td="<td id='"+orders[i].orderId+"'>"+orders[i].orderName+"</td>";
            for (let j=1;j<=7;j++){
                let isAdd=true;
                for (let k=0;k<weeks.length;k++){
                    if (j===parseInt(weeks[k])){
                        td+='<td onclick="openAutoSetup(\''+orders[i].orderId+'\','+j+')" style="cursor: pointer;">'+timeText
                        for (let i=0;i<times.length;i++){
                            td+='<input type="hidden" name="classTime" value="'+times[i]+'">';
                        }
                        td+='</td>';
                        //delete weeks[k];
                        isAdd=false;
                        break;
                    }
                }
                if (isAdd){
                    if (orders[i].orderId===orderId) {
                        td += '<td onclick="openAutoSetup(\'' + orders[i].orderId + '\',' + j + ')" style="cursor: pointer;">'+trObj.find("td:eq("+j+")").html()+'</td>';
                    }else {
                        td += '<td onclick="openAutoSetup(\'' + orders[i].orderId + '\',' + j + ')" style="cursor: pointer;"> </td>';
                    }
                }
            }
            // console.log(td);
            if (null != orderId && ''!=orderId && orders[i].orderId===orderId) {
                trObj.empty();
                trObj.append(td);
                removeTr=false;
            }else {
                let trObj=$("#autoSetup").find("tbody").find("tr:last");
                let tr="<tr id='"+orders[i].orderId+"'>"+td+"</tr>";
                trObj.before(tr);
            }
            if (removeTr){
                trObj.remove();
            }
            //更新常用老师推荐
            sysTeacherList(1);
        }
        function addTr() {
            let trObj=$("#autoSetup").find("tbody").find("tr:last");
            let tr="<tr id='"+orders[i].orderId+"'>"+td+"</tr>";
            trObj.before(tr);
        }
    }
    let iscc=[[${session.roleId==2 || session.roleId==12}]]
        if (iscc){
            $("td,tr").prop("onclick",null).off("click");
        }
    </script>
</body>
</html>
